﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;

using SPFarmModeler.Common;
using SPFarmModeler.Business;

namespace SPFarmModeler.Forms
{
    public partial class EditSPService : Form
    {
        private SPService Svc;

        public EditSPService(SPService svc)
        {
            InitializeComponent();

            Svc = svc;

            Table.ColumnCount = 2;

            // Retrieve the properties of the SPService
            PropertyInfo[] props = Svc.GetType().GetProperties();
            Table.RowCount = props.Count();
            for(int i = 0; i < props.Count(); i++)
            {
                PropertyInfo prop = props[i];

                Label lbl = new Label();
                lbl.Text = prop.Name;

                TextBox value = new TextBox();
                prop.GetValue(value.Text, null);

                Table.Controls.Add(lbl, i, 0);
                Table.Controls.Add(value, i, 1);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
